package base.system;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class AsyncScheduleDebug {
    private static final BlockingQueue<Integer> queue = new LinkedBlockingQueue<>();

    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            try {
                while (true) {
                    process(queue.take());
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        scheduler(1);
        scheduler(2);
        scheduler(3);
    }

    private static void scheduler(@org.jetbrains.annotations.Async.Execute Integer i) throws InterruptedException {
        System.out.println("scheduling " + i);
        queue.put(i);
    }

    private static void process(@org.jetbrains.annotations.Async.Execute Integer i) {
        System.out.println("processing " + i);
    }
}
